# -*- coding: UTF-8 -*-

import os
from datetime import datetime

def returnData():
    firstdata = datetime(2021, 2, 16)
    twodata = datetime.now()
    return (twodata - firstdata).days

def countDir():
    for i in range(1,returnData()+1):
        il='{}'.format(i)
        if i< 10:
            il='0{}'.format(i)
        path=os.getcwd()+'\\Day'+il
        if os.path.exists(path) :
            delDir(path)
        os.mkdir(path)
        with open(os.path.join(path,'ty.py'),'w') as f:
            pass

def  delDir(path):  #递归删除文件目录下文件夹以及文件
    filelist=os.listdir(path)
    if len(filelist)>0:
        for i in filelist:
            fpath=os.path.join(path,i)
            if os.path.isfile(fpath):
                try:
                    os.remove(fpath)
                except Exception:
                    print('delete error')
            else:
                delDir(fpath)
    os.rmdir(path)

countDir()